package devTest.Game 
{
	import flash.display.Sprite;
	import flash.display.Stage;
	import flash.text.TextField;
	import flash.text.TextFormat;
	import flash.text.TextFormatAlign;
	
	/**
	 * ...
	 * @author miquel
	 */
	public class CEndGame extends Sprite 
	{
		[Embed(source = "../../../lib/fonts/lucon.ttf",
			fontName = "Lucon", 
			mimeType = "application/x-font-truetype", 
			fontWeight="normal", 
			fontStyle="normal", 
	//			unicodeRange="englishRange", 
			advancedAntiAliasing="true", 
			embedAsCFF = "false")]
		private var myEmbeddedFont:	Class;

		//shows the message with score
		private var tKeys:						TextField 			= null;
		//stage
		private var myStage:			Stage				= null;


		/**
		 * constructor
		 */
		public function CEndGame(s:Stage) 
		{
			super();
			myStage = s;
		}
		

		
		/**
		 * Init: It receives the goals of p1 and p2 to show them
		 */
		public function Init (p1:int , p2:int):void
		{
			//prepare the message
			var l_pTextFormat:TextFormat = new TextFormat("Lucon", 40);
			tKeys = new TextField();
			tKeys.embedFonts = true;
			
			tKeys.x = 100;
			tKeys.y = 400;
			tKeys.width = 600;
			tKeys.height = 50;
			tKeys.defaultTextFormat = l_pTextFormat;
			tKeys.textColor = 0xFFFFFF;
			
			var player:String = ""
			player = (p1 > p2)? "P1" : "P2";
			
			tKeys.text = "Partido finalizado: " + p1.toString() + "-" + p2.toString() + " gana " + player;
			
			tKeys.selectable = false;
			tKeys.mouseEnabled = false;
			tKeys.background = false;
			addChild(tKeys);
		}
		
	}

}